<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Product.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=path%>/css/mine.css" type="text/css" rel="stylesheet">
    <link href="<%=path%>/css/custom.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="<%=path %>/js/dream_plugins.js"></script>
	<script type="text/javascript" src="<%=path %>/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<%=path %>/plugins/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="<%=path %>/plugins/ueditor/ueditor.all.js"></script>
	<script type="text/javascript" charset="gbk" src="<%=path %>/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
  $("#btn_upload").click(function(){
	  alert("bs");
	  var url='<%=path %>/upload';
	  alert(url);
      $.ajaxFileUpload({
          url:url,
          secureuri:true,// 安全提交，默认为false
          fileElementId:"file_upload",// 文件类型的id
          dataType:"json",// 返回值类型
          success:function(data){// 服务器响应成功
              $("#span_title2").text(data.message).css("color","red");
              $("#upload_result").show();
              $(this).attr("src","/FESWork/img/right2.png");
          },
          error:function(data){// 服务器响应失败
              $("#span_title2").text(data.message).css("color","red");
          }
      }); 
      return false; 
  });
  });
  
  function saveproduct(value){
	  var url = '<%=path%>/Product_saveproduct?productid='+value;
	  $.ajax({
		    cache: true,
			type: 'POST',
			url:url,
			data:$('#mytable').serialize(),	 
			async: false,
			error: function(request) {
			alert("发送请求失败！"+request.responseText);
			},
			success: function(data) {
			alert("保存成功");
			$(location).attr('href','<%=path%>/Product_AllProduct');
			}
			});
	  }
  
  

  </script>
  </head>
  
  <body>
  <div class="div_head">
		<span> <span style="float:left">当前位置是：产品管理 》 添加产品</span> <span
			style="float:right;margin-right: 8px;font-weight: bold"> <a
				style="text-decoration: none" href="./admin.php?c=goods&a=showlist">【主页】</a>
		</span>
		</span>
	</div>
  <div>
  <form id="mytable" method="post">
  <table id="kk" cellSpacing="10" cellPadding="10" align="center"
		border="2" style="width:100%;">
		
		<tr align="center">
		 <td>产品名称：<input type="hidden" id="product.CId" name="product.CId" value="${request.product.CId}" /></td>
		 <td align="left"> <input type="text" id="product.CName" name="product.CName" value="${request.product.CName}" style="width:300px;height:20px" >
		 </td>
		</tr>
		<tr align="center">
		 <td>产品类别：</td>
		 <td align="left"> 
		 <select name="CNameT" id="CNameT">
		  <option selected="selected" >${request.product.CNameB}</option>
		  <s:iterator value="#request.protype " var="p">
		     <option >${p.CName}</option>
          </s:iterator>
		  </select>
		 </td>
		</tr>
		<%-- <tr align="center">
		 <td>二级类型名：</td>
		 <td align="left"> <input type="text" id="CName" name="CName" value="${request.product.CNameB}" style="width:300px"></td>
		</tr> --%>
		
		<tr align="center">
		 <td>简介：</td>
		 <td align="left"> 
         <input type="text"  name="product.CIntro" id="product.CIntro" value="${request.product.CIntro}" style="width:300px">		 
		 
		 </td>
		</tr>
		<tr align="center">
		 <td>型号：</td>
		 <td align="left"> <input type="text" name="product.CCode" id="product.CCode" value="${request.product.CCode}" style="width:300px"></td>
		</tr>
		
		<tr align="center">
		 <td>详细描述：</td>
		 <td align="left"> 
		 <textarea rows="" cols="" name="description" id="editor"  style="height:450px;width:800px">${request.CDescription}</textarea> 
	<%--  <div style="width:90%;">
    	<textarea rows="" cols="" id="CINTRO" name="CINTRO" style="display:none;">${request.CINTRO }</textarea>
    	<textarea rows="" cols="" id="CINTROE" name="CINTROE" style="display:none;">${request.CINTROE }</textarea>
    	<!-- <input type="button" value="保存为中文" onclick="SaveText('textform', 'CINTRO');" />&emsp;
    	<input type="button" value="保存为英文" onclick="" />&emsp;
    	<input type="button" value="预览效果" />&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
    	<input type="button" id="fillchinese" value="填充中文内容" onclick="FillChineseContent();" />&emsp;
    	<input type="button" id="fillenglish" value="填充英文内容" onclick="FillEnglishContent();" /> -->
    </div --%>
		 
		 </td>
		</tr>
		
		<%-- <tr align="center">
		 <td>缩略图：</td>
		 <td align="left"> 
		 <iframe id="product.CPicmin" name="product.CPicmin" height="200px" frameborder="0" src="<%=path%>/jsp/Product/ProductPicturel.jsp">
		 </iframe> 
		 <input type="file" name="file_upload" id="file_upload" style="width: 360px">
         <input value="上传并解析" type="button" id="btn_upload" name="btn_upload"  align="middle" style="width: 100px; height: 30px">         
		 </td>
		</tr> --%>
		
		<tr align="center">
		 <td>价格：</td>
		 <td align="left"> <input type="text" name="product.CPrice" id="product.CPrice" value="${request.product.CPrice}" style="width:60px">元</td>
		</tr>
	
		
		 <tr>
		
		 <tr align="center">
		 <td></td>
		 <td><input type="button" value="保存" onclick="saveproduct('${request.product.CId}');"><input type="button" value="重置"></td>
		</tr> 
  </table>
 </form>
<script type="text/javascript">
    var editor = new baidu.editor.ui.Editor({
    	UEDITOR_HOME_URL : '/CMSProject/plugins/ueditor/',
    	autoClearinitialContent : false,
    	iframeCssUrl : '/CMSProject/plugins/ueditor/default/iframe.css',
    	textarea:'content',
    	enableAutoSave: false,
    	autoHeightEnabled: false,
        fullscreen : false, //是否开启初始化时即全屏，默认关闭
        toolbars:[
                  ['fullscreen', 'source', '|', 'undo', 'redo', '|',
                      'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 
                      'formatmatch', 'hougelou', 'autotypeset', 'blockquote', 'pasteplain', 
                      '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                      'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                      'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                      'directionalityltr', 'directionalityrtl', 'indent', '|',
                      'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                      'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                      'simpleupload','insertimage', 'emotion', 'attachment', 'map', 'insertframe', 'pagebreak', 'background', '|',
                      'horizontal', 'date', 'time', 'spechars', 'snapscreen', '|',
                      'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 
                      'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',
                      'preview', 'searchreplace', 'help']
              ]
    });
    editor.render('editor');
    </script>
   
   </div>
  </body>
</html>
